package com.lds.management.center.common.exception;

import com.lds.management.center.common.enums.ErrCodeEnum;
import lombok.Getter;

/**
 * 自定义业务异常
 *
 * @version V1.0
 */
@Getter
public final class BusinessException extends RuntimeException {

    private ExceptionMessage exceptionMessage;

    private BusinessException() {}

    public BusinessException(String errorCode, String errorMessage) {
        exceptionMessage = new ExceptionMessage(errorCode, errorMessage);
    }

    public BusinessException(ErrCodeEnum errCodeEnum) {
        this(errCodeEnum.getErrCode(), errCodeEnum.getErrMsg());
    }

    @Override
    public String getMessage() {
        return exceptionMessage.getMessage();
    }

}
